<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>键盘事件</title>
    <script>
        function f1(){
            console.log("按下了");
        }
        function f2(){
            console.log("松开了");
        }
        function f3(){
            console.log("按下并松开了");
        }
    </script>
</head>
<body>
<input type="text" onkeydown="f1()" onkeyup="f2()" onkeypress="f3()">
</body>
</html>